import 'package:elephant_fish/util/size_util.dart';
import 'package:elephant_fish/widget/text_fild.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class RegisterPage extends StatefulWidget {
  const RegisterPage({Key key}) : super(key: key);

  @override
  _RegisterPageState createState() => _RegisterPageState();
}

class _RegisterPageState extends State<RegisterPage> {
  TextEditingController _nameController = TextEditingController();
  TextEditingController _passwordController = TextEditingController();
  TextEditingController _rePasswordController = TextEditingController();
  TextEditingController _vcodeController = TextEditingController();
  //分别定义两个输入框的焦点 用于切换焦点
  final FocusNode _nodeName = FocusNode();
  final FocusNode _nodePwd = FocusNode();
  final FocusNode _nodeVCode = FocusNode();
  bool _isClick = false;

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: SingleChildScrollView(
        child: Container(
          alignment: Alignment.topCenter,
          width: MediaQuery.of(context).size.width,
          height: MediaQuery.of(context).size.height,
          decoration: BoxDecoration(
            image: new DecorationImage(
              fit: BoxFit.cover,
              image: AssetImage('assets/images/register_bg.png'),
            ),
            gradient: LinearGradient(
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              colors: [Color(0xffff9182), Color(0xffff849b)],
            ),

          ),
          child: Stack(
            children: [
              Align(
                alignment: Alignment.topCenter,
                child: Padding(
                  padding: EdgeInsets.only(top: SizeUtil.px(179)),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Image.asset('assets/images/logo.png',width: SizeUtil.px(57.72),height: SizeUtil.px(56),),
                      SizedBox(width: SizeUtil.px(25),),
                      Text('象鱼直播',style: TextStyle(fontSize: SizeUtil.px(56),color: Color(0xffffffff))),

                    ],
                  ),
                ),
              ),
              Align(
                alignment: Alignment.topCenter,
                child: Padding(
                  padding: EdgeInsets.only(left: SizeUtil.px(60),right: SizeUtil.px(60),top: SizeUtil.px(366)),
                  child: MyTextField(
                    focusNode: _nodeName,
                    placeHolder: '请输入您的手机号',
                    maxLength: 11,
                    keyboardType: TextInputType.phone,
                    controller: _nameController,
                  ),
                ),
              ),
              Align(
                alignment: Alignment.topCenter,
                child: Padding(
                  padding: EdgeInsets.only(left: SizeUtil.px(60),right: SizeUtil.px(60),top: SizeUtil.px(486)),
                  child: MyTextField(
                  focusNode: _nodeVCode,
                  placeHolder: '请输入验证码',
                  maxLength: 6,
                  controller: _vcodeController,
                  keyboardType: TextInputType.phone,
                  getVCode: () {
                    print('获取验证码');
                  },
                ),

              ),
              ),
              Align(
                alignment: Alignment.topCenter,
                child: Padding(
                  padding: EdgeInsets.only(left: SizeUtil.px(60),right: SizeUtil.px(60),top: SizeUtil.px(606)),
                  child: MyTextField(
                    focusNode: _nodePwd,
                    placeHolder: '请输入新密码',
                    controller: _passwordController,
                    isInputPwd: true,


                  ),

                ),
              ),
              Align(
                alignment: Alignment.topCenter,
                child: Padding(
                  padding: EdgeInsets.only(left: SizeUtil.px(60),right: SizeUtil.px(60),top: SizeUtil.px(726)),
                  child: MyTextField(
                    focusNode: _nodePwd,
                    placeHolder: '请重复输入新密码',
                    controller: _rePasswordController,
                    isInputPwd: true,


                  ),

                ),
              ),
              Align(
                alignment: Alignment.topCenter,
                child: Padding(
                  padding: EdgeInsets.only(left: SizeUtil.px(60),right: SizeUtil.px(60),top: SizeUtil.px(950)),
                  child: Container(
                    width: SizeUtil.px(650),
                    height: SizeUtil.px(91),
                    child: RaisedButton(
                      shape: RoundedRectangleBorder(
                        side: BorderSide.none,
                        borderRadius: BorderRadius.all(Radius.circular(30)),
                      ),
                      color: Color(0xffe62d6c),
                      disabledColor: Color(0xffe62d6c),
                      child: Text(
                        '修改密码',
                        style: TextStyle(fontSize: SizeUtil.px(36),color: Color(0xffffffff)),
                      ),
                      onPressed: (){
                        print("修改密码");
                      },
                    ),

                  )
                ),
              ),
              Align(
                alignment: Alignment.topCenter,
                child: Padding(
                  padding: EdgeInsets.only(top: SizeUtil.px(1061)),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Container(
                        width: SizeUtil.px(24),
                        height: SizeUtil.px(24),
                        child:  Checkbox(value: _isClick, onChanged: (bool value){
                          setState(() {
                            _isClick = value;
                          });
                        },checkColor: Color(0xffffffff) ,materialTapTargetSize:MaterialTapTargetSize.shrinkWrap),
                      ),
                      SizedBox(width: SizeUtil.px(5),),
                      Text('我已看过并接受《用户协议》',style: TextStyle(fontSize: SizeUtil.px(24),color: Color(0xffffffff))),

                    ],
                  ),
                ),
              ),
            ],
          ),

        ),
      ),
    );
  }
}
